This is the analysis script to prepare the data to run analyses for the project “Anxiety, depression and trauma symptom change during the COVID-19 pandemic: retrospective versus objective assessment” - Young et al (2020)
Script written by K L Purves, K N Thompson, C Huebel and M Davies. Email: kirstin.purves@kcl.ac.uk, katie.thompson@kcl.ac.uk, christopher.1.huebel@kcl.ac.uk, molly.davies@kcl.ac.uk
#Set up
Clear global environment
Retrieve the current date to use it for file endings to not overwrite files when one exports files
#Packages Install packages (if they are not available in your version of R)
Load packages
Registered S3 method overwritten by 'pryr':
method from
print.bytes Rcpp
For best results, restart R session and update pander using devtools:: or remotes::install_github('rapporter/pander')
Attaching package: 'polycor'
The following object is masked from 'package:psych':
polyserial
corrplot 0.84 loaded
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.2 ✓ purrr 0.3.4
✓ tibble 3.0.4 ✓ dplyr 1.0.2
✓ tidyr 1.1.2 ✓ stringr 1.4.0
✓ readr 1.3.1 ✓ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x ggplot2::%+%() masks psych::%+%()
x ggplot2::alpha() masks psych::alpha()
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
x tibble::view() masks summarytools::view()
FunctionLib/lm_forest.R FunctionLib/lm_formula.R
value ? ?
visible FALSE FALSE
FunctionLib/lm_output.R FunctionLib/raincloud.R
value ? ?
visible FALSE FALSE
Define colours for plotting this are the standard coping colours
Choose in this chunk which palette to use 04.07.2020 - Default to 2 colour COPING palette
Set up ggplot theme for the plots
[1] 31884 641
[1] "gad.sum_score_prepan" "pcl.sum_score_prepan"
[3] "phq.sum_score_prepan" "phq.sum_score_8items_prepan"
[5] "ocir.sum_score_prepan" "gad.sum_score_base"
[7] "gad.sum_score_retro" "pcl.sum_score_base"
[9] "pcl.sum_score_retro" "phq.sum_score_base"
[11] "phq.sum_score_8items_base" "phq.sum_score_retro"
[13] "phq.sum_score_8items_retro" "ocir.sum_score_base"
[15] "ocir.sum_score_retro"
[1] "phq.sum_score_prepan" "phq.sum_score_base" "phq.sum_score_retro"
[1] "gad.sum_score_prepan" "gad.sum_score_base" "gad.sum_score_retro"
[1] "ocir.sum_score_prepan" "ocir.sum_score_base" "ocir.sum_score_retro"
[1] "pcl.sum_score_prepan" "pcl.sum_score_base" "pcl.sum_score_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro" "gad.diff_score_retro_prepan"
[5] "gad.diff_score_base_prepan" "gad.diff_score_base_retro"
[7] "pcl.diff_score_base_prepan" "ocir.diff_score_retro_prepan"
[9] "ocir.diff_score_base_prepan" "ocir.diff_score_base_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro"
[1] "gad.diff_score_retro_prepan" "gad.diff_score_base_prepan"
[3] "gad.diff_score_base_retro"
[1] "ocir.diff_score_retro_prepan" "ocir.diff_score_base_prepan"
[3] "ocir.diff_score_base_retro"
#ANALYSIS PLAN 1. Calculate mean change per disorder group i. Disorders (9) a. Rank the disorders by the size of the change ii. Sex iii. Age (13; RAMP; potentially collapse above 65 depending on group sizes) iv. Ethnicity groups (5; White European, Black (British), Asian, Arab, Mixed)
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad sum score summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base | 0 | 21 | 2.665863 | 0.0 | 4.451322 | 2.1775181 | 4.4518534 |
| No change | Prepan | 0 | 21 | 8.254932 | 7.0 | 6.202852 | 0.4754996 | -0.9032129 |
| No change | Retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| Worsening | Base | 0 | 21 | 8.695957 | 7.0 | 5.696058 | 0.5245479 | -0.8011604 |
| Worsening | Prepan | 0 | 21 | 9.403875 | 8.0 | 5.859497 | 0.3389671 | -0.9329372 |
| Worsening | Retro | 0 | 21 | 4.638103 | 4.0 | 4.279377 | 1.3752419 | 1.9313176 |
| Improvement | Base | 0 | 21 | 4.771279 | 3.0 | 4.830869 | 1.3672217 | 1.5731623 |
| Improvement | Prepan | 0 | 21 | 9.228041 | 8.0 | 5.817921 | 0.3295928 | -0.9032305 |
| Improvement | Retro | 0 | 21 | 8.362857 | 7.0 | 5.468934 | 0.5124932 | -0.5869968 |
| NA | Base | 0 | 21 | 5.700000 | 4.5 | 5.994045 | 1.0357477 | 0.1012029 |
| NA | Prepan | 0 | 21 | 10.000000 | 13.0 | 8.563488 | -0.0313927 | -1.9895986 |
| NA | Retro | Inf | -Inf | NaN | NA | NA | NA | NA |
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad diff summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base - prepan | -21 | 20 | -2.0498783 | -1 | 4.730325 | -0.4870231 | 1.5079948 |
| No change | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| No change | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| Worsening | Base - prepan | -18 | 21 | 0.9694803 | 1 | 5.309832 | -0.0145504 | 0.6007935 |
| Worsening | Base - retro | -21 | 21 | 4.0587466 | 3 | 4.286868 | 0.7700269 | 0.8792915 |
| Worsening | Prepan - retro | -21 | 18 | -3.5772884 | -3 | 5.108094 | -0.2892807 | 0.4412892 |
| Improvement | Base - prepan | -21 | 12 | -4.0760778 | -3 | 5.490428 | -0.2970813 | 0.1264514 |
| Improvement | Base - retro | -21 | 21 | -3.5866667 | -3 | 5.322797 | 0.4752668 | 2.1484694 |
| Improvement | Prepan - retro | -21 | 20 | 0.3536379 | 1 | 5.692678 | -0.1576467 | 0.8754152 |
| NA | Base - prepan | -9 | 6 | -1.5000000 | -2 | 5.431390 | 0.0468089 | -1.6798094 |
| NA | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| NA | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
makes this into percentages
Warning: Removed 56536 rows containing non-finite values (stat_count).
Warning: Removed 33099 rows containing non-finite values (stat_bin).
Warning: Removed 33099 rows containing non-finite values (stat_bin).
Warning: Removed 23437 rows containing non-finite values (stat_bin).
Warning: Removed 33099 rows containing non-finite values (stat_bin).
Warning: Removed 33099 rows containing non-finite values (stat_bin).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 33099 rows containing non-finite values (stat_ydensity).
Warning: Removed 33099 rows containing non-finite values (stat_summary).
Warning: Removed 33099 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 33099 rows containing non-finite values (stat_ydensity).
Warning: Removed 33099 rows containing non-finite values (stat_summary).
Warning: Removed 33099 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 33099 rows containing non-finite values (stat_ydensity).
Warning: Removed 33099 rows containing non-finite values (stat_summary).
Warning: Removed 33099 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 33099 rows containing non-finite values (stat_ydensity).
Warning: Removed 33099 rows containing non-finite values (stat_summary).
Warning: Removed 33099 rows containing missing values (geom_point).